function phiv = dreumFlow4(H,K,phi,tc,theta,type)				
% Calculate single-period (flow) utility for each site choice 


% Define parameters
% eta = [0 theta(2) theta(3)];
eta = [theta(2) theta(3) 0];
chi = theta(6:end-2);
mu = theta(1);
Nu=size(tc,1);


% Calculate flow utility
phiv = zeros(H+1,K,Nu);

for idx1 = 1:H-1 % PP-only (idx1 = 0) has no chi and tc = 0, so not included in loop
                % Same for opt-out (idx1 = 23) 
	for idx2 = 1:K

		phi1 = phi(idx1+1,idx2); % Set probability of success
	
		for idx3 = 1:Nu  

% 			mc = tc(idx3,idx1); 
%             oc = tc(idx3,idx1+H-1);% Look up travel costs
%             
            tc1 = tc(idx3,idx1);

			phiv(idx1+1,idx2,idx3) = phi1*(chi(idx1) + eta(type) + tc1*mu);
					
		end 
	
	end

end
